//
//  smHourseDetailController.m
//  shimaoHouse
//
//  Created by amy zhang on 12-6-28.
//  Copyright (c) 2012年 yst. All rights reserved.
//

#import "smHourseDetailController.h"
#import "HTTPImageView.h"
#import "CoverFlowView.h"
#import "smOrderInfoController.h"
#import "smMboSmTbHouse.h"

@interface smHourseDetailController()<UIScrollViewDelegate>  

@property (nonatomic, strong) smMboSmTbHouse* house;
@property (nonatomic,strong) UIScrollView *scrollView;

@end

@implementation smHourseDetailController

@synthesize house = _house;
@synthesize scrollView = _scrollView;

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    //[self setTitle:@"房源信息"];
    
    [self.navigationController.navigationBar setHidden:YES];
    
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"house_info.png"]]];
    

    
    UILabel* programnameLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 80, self.view.bounds.size.width, 30)];
    [programnameLabel setBackgroundColor:[UIColor clearColor]];
    [programnameLabel setText:@"项目名称：新明半岛水岸轩"];
     programnameLabel.font = [UIFont systemFontOfSize:25];
    [programnameLabel setTextColor:[UIColor colorWithRed:126/255.0 green:126/255.0 blue:126/255.0 alpha:1.0]];
    [self.view addSubview:programnameLabel];
     
    
    //self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(60, 32, self.view.bounds.size.width, 300)];
    //[self.scrollView setDelegate:self];
    
     self.view.frame = CGRectMake(20, 180, self.view.bounds.size.width, 300);
    NSMutableArray *sourceImages = [NSMutableArray arrayWithCapacity:5];
    for (int i = 1; i <6 ; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"huxing%d.jpg", i]];
        [sourceImages addObject:image];
    }
    
    
    CoverFlowView *coverFlowView = [CoverFlowView coverFlowViewWithFrame:self.view.frame andImages:sourceImages sideImageCount:2 sideImageScale:0.3 middleImageScale:0.6];
    [self.view addSubview:coverFlowView];
    
   
  //  UIImage* tempImg = [UIImage imageNamed:@"hourse.jpg"];
    
  //  UIImageView *imgView =[[UIImageView alloc] initWithImage:tempImg];
    
    // HTTPImageView* imgView = [[HTTPImageView alloc] init];
    
    //[imgView setPlaceHolder:tempImg];
    
    // [imgView setUrl:@"http://www.qiqu5.com/wp-content/uploads/2010/03/119.jpg"];
    
   // [self.scrollView addSubview:imgView];
    
    
     //HTTPImageView* imgView1 = [[HTTPImageView alloc] init];
    
    //[imgView1 setPlaceHolder:tempImg];
    
   //  [imgView1 setUrl:@"http://www.dabaoku.com/sucaidatu/fangdichan/jingdianloupan/034456.jpg"];
    
    //[self.scrollView addSubview:imgView1];
    
  //  [self.view addSubview:self.scrollView];
    
    int messageHight =660;
    
    UILabel* hoursenameLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, messageHight-35, 400, 30)];
    [hoursenameLabel setBackgroundColor:[UIColor clearColor]];
    //[hoursenameLabel setText:@"新明半岛水岸轩15＃3－201"];
    [hoursenameLabel setText:[NSString stringWithFormat:@"%@",[self.house name]]];
    [hoursenameLabel setTextColor:[UIColor whiteColor]];
    hoursenameLabel.font=[UIFont systemFontOfSize:27];
    [self.view addSubview:hoursenameLabel];
    
    UILabel* statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, messageHight+10, 400, 30)];
    [statusLabel setBackgroundColor:[UIColor clearColor]];
    //[statusLabel setText:@"当前状态：在售"]; 
     [statusLabel setText:[NSString stringWithFormat:@"当前状态：%@",[self.house status]]];
    [statusLabel setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
    statusLabel.font=[UIFont systemFontOfSize:23];
    [self.view addSubview:statusLabel];
    
    UILabel* sizelable = [[UILabel alloc]initWithFrame:CGRectMake(40, messageHight+40, 300, 30)];
    [sizelable setBackgroundColor:[UIColor clearColor]];
    //sizelable.text = @"面积：150平米";
     [sizelable setText:[NSString stringWithFormat:@"面积：%@平米",[self.house area]]];
    [sizelable setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
    sizelable.font = [UIFont systemFontOfSize:23];
    [self.view addSubview:sizelable];
    
    UILabel* moneylable = [[UILabel alloc]initWithFrame:CGRectMake(40, messageHight+70, 300, 30)];
    [moneylable setBackgroundColor:[UIColor clearColor]];
    //moneylable.text = @"总价：200万";
     NSUInteger a=[self.house unitPrice].intValue*[self.house area].intValue;
    [moneylable setText:[NSString stringWithFormat:@"总价：%d万",a/10000]];
     [moneylable setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
    moneylable.font = [UIFont systemFontOfSize:23];
    [self.view addSubview:moneylable];
    
    UILabel* huxinglable = [[UILabel alloc]initWithFrame:CGRectMake(40, messageHight+100, 300, 30)];
      [huxinglable setBackgroundColor:[UIColor clearColor]];
    //huxinglable.text = @"户型：三房两厅两卫两阳台";
     [huxinglable setText:[NSString stringWithFormat:@"户型：%@",[self.house huxing]]];
    huxinglable.font = [UIFont systemFontOfSize:23];
     [huxinglable setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
    [self.view addSubview:huxinglable];
        
    UILabel* priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, messageHight+130, 300, 30)];
      [priceLabel setBackgroundColor:[UIColor clearColor]];
    //[priceLabel setText:@"单价：18000元/平米"];
    [priceLabel setText:[NSString stringWithFormat:@"单价：%@元/平米",[self.house unitPrice]]];
    [priceLabel setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
    priceLabel.font=[UIFont systemFontOfSize:23];
    [self.view addSubview:priceLabel];
    
    
    UILabel* placeLabel = [[UILabel alloc] initWithFrame:CGRectMake(360, messageHight+10, 300, 30)];
    [placeLabel setBackgroundColor:[UIColor clearColor]];
    //[placeLabel setText:@"详细位置：古墩路与天目山路交叉口"];
     [placeLabel setText:[NSString stringWithFormat:@"详细位置：%@",[self.house place]]];
     placeLabel.font=[UIFont systemFontOfSize:23];
     [placeLabel setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
    [self.view addSubview:placeLabel];
    
    UILabel* regionLabel = [[UILabel alloc] initWithFrame:CGRectMake(360, messageHight+40, 300, 30)];
      [regionLabel setBackgroundColor:[UIColor clearColor]];
    //[regionLabel setText:@"所属区域：杭州市西湖区"];
     [regionLabel setText:[NSString stringWithFormat:@"所属区域：%@",[self.house region]]];
     [regionLabel setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
    regionLabel.font=[UIFont systemFontOfSize:23];
    [self.view addSubview:regionLabel];
    
    UILabel* buildyearLabel = [[UILabel alloc] initWithFrame:CGRectMake(360, messageHight+70, 300, 30)];
    [buildyearLabel setBackgroundColor:[UIColor clearColor]];
    //[buildyearLabel setText:@"建筑年代：2012年"];
     [buildyearLabel setText:[NSString stringWithFormat:@"建筑年代：%@",[self.house buildYear]]];
    buildyearLabel.font=[UIFont systemFontOfSize:23];
     [buildyearLabel setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
    [self.view addSubview:buildyearLabel];
    
    UILabel* foorLabel = [[UILabel alloc] initWithFrame:CGRectMake(360, messageHight+100, 300, 30)];
    [foorLabel setBackgroundColor:[UIColor clearColor]];
    //[foorLabel setText:@"总楼层：17层"];
     [foorLabel setText:[NSString stringWithFormat:@"总楼层：%@",[self.house floor]]];
     [foorLabel setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
    foorLabel.font=[UIFont systemFontOfSize:23];
    [self.view addSubview:foorLabel];
    
    UILabel* companyLabel = [[UILabel alloc] initWithFrame:CGRectMake(360, messageHight+130, 300, 30)];
    [companyLabel setBackgroundColor:[UIColor clearColor]];
    //[companyLabel setText:@"物业公司：西城物业"];
     [companyLabel setText:[NSString stringWithFormat:@"物业公司：%@",[self.house serviceCompany]]];
    companyLabel.font=[UIFont systemFontOfSize:23];
     [companyLabel setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
    [self.view addSubview:companyLabel];
    
    
    
    UIButton* candelButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [candelButton setFrame:CGRectMake(25, messageHight+182, 282, 73)];
    //[candelButton setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"cancel_button_up.png"]]];
    [candelButton setImage:[UIImage imageNamed:@"cancel_button_up.png"] forState:UIControlStateNormal];
    [candelButton setImage:[UIImage imageNamed:@"cancel_button_down.png"] forState:UIControlStateHighlighted];
    candelButton.backgroundColor=[UIColor clearColor];
    
	[candelButton addTarget:self action:@selector(cancelButtonPress:) forControlEvents:UIControlEventTouchUpInside]; //定义点击时的响应函数
    
    [self.view addSubview:candelButton];
    
    UIButton* orderButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [orderButton setFrame:CGRectMake(463, messageHight+182, 282, 73)];
   // [orderButton setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"yuding_button_up"]]];
    [orderButton setImage:[UIImage imageNamed:@"yuding_button_up.png"] forState:UIControlStateNormal];
    [orderButton setImage:[UIImage imageNamed:@"yuding_button_down.png"] forState:UIControlStateHighlighted];
    orderButton.backgroundColor=[UIColor clearColor];
    
	[orderButton addTarget:self action:@selector(orderButtonPress:) forControlEvents:UIControlEventTouchUpInside]; //定义点击时的响应函数
    
    
    [self.view addSubview:orderButton];
    

}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


-(void) setitems: (smMboSmTbHouse*) obj  {
    
    self.house=obj;
    
}

-(void) cancelButtonPress: (UIButton*) bt {
    [self.navigationController popViewControllerAnimated:YES];
}
-(void) orderButtonPress:(UIButton*) bt {
    smOrderInfoController* orderInfoController = [[smOrderInfoController alloc] init];
    [self.navigationController pushViewController:orderInfoController animated:YES]; 
}



@end
